package cuiyt.datastructure.search;

/**
 * @author cyt
 * @create 2020-08-29 11:08
 */
public class SeqSearch {

    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 4, 5, 6, 7};
        int i = find(arr, 4);
        System.out.println(i);
    }

    /**
     * 递归版本
     * @return
     */
    public static int  BinarySearch1(){


        return 1;
    }


    /**
     * 顺序查找算法
     *
     * @param arr
     * @param target
     * @return
     */
    public static int find(int[] arr, int target) {
        int ans = -1;
        for (int i = 0; i < arr.length; i++) {
            if (target == arr[i]) {
                ans = target;
            }
        }
        return ans;
    }
}
